import {createSlice} from '@reduxjs/toolkit';

interface MenuItem {
    children: Child[];
    icon: string;
    key: string;
    name: string;
    [property: string]: any;
}

interface Child {
    key: string;
    name: string;
    title: string;
    [property: string]: any;
}

export const menuSlice = createSlice({
    name: 'menu',
    initialState: {
        menuList: [] as MenuItem[],
    },
    reducers: {
        setMenuList: (state: any, action) => {
            state.menuList = action.payload;
        },
    },
});

// 每个 case reducer 函数会生成对应的 Action creators
export const {setMenuList} = menuSlice.actions;

export default menuSlice.reducer;
